package bg.btanev.eightyfour.client.service;

import java.io.Serializable;

import bg.btanev.eightyfour.shared.command.CommandAction;
import bg.btanev.eightyfour.shared.command.CommandInput;
import bg.btanev.eightyfour.shared.command.CommandResult;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

@RemoteServiceRelativePath("gwtfacede/gwtCommandService")
public interface GWTCommandService extends RemoteService {
	/**
	 * Utility class for simplifying access to the instance of async service.
	 */
	public static class Util {
		@SuppressWarnings("unchecked")
		private static GWTCommandServiceAsync instance;

		@SuppressWarnings("unchecked")
		public static GWTCommandServiceAsync getInstance() {
			if (instance == null) {
				instance = GWT.create(GWTCommandService.class);
			}
			return instance;
		}
	}

	<I extends CommandInput, R extends Serializable, CR extends CommandResult<I, R>, CA extends CommandAction<I, CR>> CR executeCommand(
			CA commandAction);
}
